Dreamweaver Article

How to Develop an Online Shopping Cart (Part Two)


Table of Contents

  1. Introduction
  2. Business Logic
  3. Security and Liability
  4. Processing Credit Cards Online

Processing Credit Cards Online

This can be a little frustrating, so I will break down the options available to you into their basic components and walk through them one by one. It's not as bad as it seems. First, I’ll talk about what the options are, and then I will discus how to integrate them into your site. There are three basic components to online payment processing:

  • Merchant account
  • Payment gateway
  • Interface between your site and the gateway

Merchant Accounts

First, what is a merchant account? A merchant account is simply a business bank account that you set up to accept payment through credit cards. Almost any bank can open a merchant account, but it is very important to find one that is Internet savvy. An Internet friendly business account is not just a business bank account or credit card account. The kind of merchant bank I am talking about is one that is familiar with interfacing with Internet payment gateways. This is the interface between your site and your bank. I'll get to those in a minute. Be sure to check this out before setting up an account. Doing your homework and asking pointed questions can save you a great deal of frustration, time, and money.

Don't get trapped! What many merchant accounts won't tell you, unless you specifically ask, is they will only interface with their own proprietary gateway. This could lead to a lot of custom programming and trouble that you could avoid if you were to go with a more common third party solution. Rates vary from bank to bank—a lot! Again, do your homework. Often times it is less expensive to even have a different merchant bank for your website than for your business.

Okay, you're a web developer and this is up to your client right? True, but by discussing these simple facts with your client you can become very popular when your advice in this area saves your client a bunch of money. A happy client is a paying client.

Payment Gateways and Payment Processors

Really, there are only two choices. Companies offering some kind of Internet payment processing are springing up everywhere. It's like how many kinds of cereal can you find in the breakfast isle at the grocery store? But all of these choices can be boiled down to two basic types.

  • Real time/payment gateways–real-time results
  • Non-Real Time/payment processors–results later

There are more differences between these two than just the speed at which they communicate with your application—differences that will directly affect your application. Maybe even your sanity! (Just kidding, kind of.) Let's examine the differences.

Real-Time Payment Gateways—In-Line Processing or Immediate Transactions

Your true payment gateways process the credit card authorization in–line. The shopping cart application will process the page until it reaches the code that interacts with the gateway. It will then pause while it waits for a response from the gateway. Once it receives the response, the shopping cart application server will then continue to process the page.

Figure 2. Payment gateway process flow

Figure 2. Payment gateway process flow

Advantages:

  • Instant feedback to the customer
  • You can base page logic on transaction results
  • If the transaction is unsuccessful, you can give the user an opportunity to try again.
  • Code to integrate is usually less complex
  • Cheaper in the long run, for higher volume business.

Disadvantages:

  • More difficult to set up (Merchant Accounts, Gateway Vendors, Credit requirements)
  • More expensive to set up initially and may be more expensive overall for low volume businesses

The most popular real time payment gateways are Verisign PayFlow Pro and Authorize Net. Verisign sells their service directly, while Authorize Net sells through a network of resellers. Authorize Net tends to be cheaper to set up and charges a more reasonable percentage

Payment Processors—"We'll Take Care Of This & Get Back To You"

Payment processors work quite differently. When your application server comes to the code that interfaces with the payment processor, it sends the information off—usually in form variables, but sometimes as URL variables. After sending the data, the server finishes the page and doesn't wait for any response. The results of the transaction will have to be handled later.

Note: A word about sending cart information via URL variables: Don't do it! A URL variable is the most accessible and hackable bit of information passed on the web. This is not a place to put your pricing information, or worse yet, credit card data. If you're looking at a payment processor that requires you to send cart or customer data through URL variables, look elsewhere. You've been warned.

Was the credit card approved or not? We'll have to wait and see. Payment processors will send the results of the transaction back to you, either by e-mail or through an HTTP post to a designated page. Getting a response can take anywhere from a few seconds to a day or two.

Figure 3. Payment processor process flow

Figure 3. Payment processor process flow

Advantages:

  • Easier to set up, usually do not require a commercial merchant account.
  • Usually do not have credit restrictions or require a business license.
  • Very low cost or free to set up.

Disadvantages:

  • Transaction is not processed in real-time. Does not provide instant feedback.
  • Often require the customer to leave your site to complete the transaction.
  • Results of the transaction delayed from seconds to days.
  • Code to integrate is more complex. The results of the transaction must be retrieved manually or by HTTP post and you will have to update your order records.
  • If the customer's credit card is declined, the user will be informed after their shopping session is over and they may not return to try again, resulting in lost sales.

Considering their speed disadvantage, why would anyone choose to use a payment processor over a payment gateway? The simple reason is usually convenience and price.

A Word About Customer Service

For the most part, customer service afforded the web developer by the payment processors and gateway vendors is less than noteworthy. Unfortunately, this is pretty much norm. PayPal has over the last year made some real strides in this respect with their Developer's Network. And some of the Authorize Net resellers do a better than usual job of answering your questions. But as a developer, it mostly boils down to biting the bullet by spending the time and making the effort to learn how your system of choice works and how to integrate with it.

In part three, I bring this all together by taking you through developing a small e-commerce application and seeing how it all fits together. You will build a small database, develop a cart, and an example of a secure administrative back end.